<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form id="form"  >
                <p:growl />

                <p:panel header="Manage Investigation" >
                    <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop" >

                        <h:panelGrid id="gpSelect" columns="1"  >
                            <p:panel header="Search Investigation" >
                                <h:panelGrid id="gpSelectText" >

                                    <h:inputText autocomplete="off" id="txtSearch" value="#{investigationController.selectText}" >
                                        <f:ajax execute="txtSearch" render="lstSelect" event="keyup" />
                                    </h:inputText>

                                    <p:selectOneListbox converter="ixcon"   id="lstSelect"   value="#{investigationController.current}" style="min-width: 223px; height: 300px;">
                                        <f:selectItems  value="#{investigationController.selectedItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                        <p:ajax event="change"   update="gpDetail" process="lstSelect" >
                                        </p:ajax>
                                    </p:selectOneListbox>


                                </h:panelGrid>
                                <h:panelGrid id="gpSelectButtons" columns="3"  >
                                    <h:commandButton id="btnAdd" value="Add" action="#{investigationController.prepareAdd()}" styleClass="buttons" >
                                        <f:ajax render="btnAdd  btnDelete btnSave   lstSelect gpDetail " execute="" >
                                        </f:ajax>
                                    </h:commandButton>
                                    <h:commandButton id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                        return false;" action="#{investigationController.delete()}"  value="Delete"  >
                                    </h:commandButton>


                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid  >

                        <p:panel header="Edit Details">
                            <f:facet name="header" >
                                <h:outputLabel value="Edit Details" ></h:outputLabel>
                                <p:commandButton style="float:right;" id="btnSave" value="Save"  action="#{investigationController.saveSelected()}" styleClass="buttons" 
                                               ajax="false" onclick="onSubmitButton();"  >
                                </p:commandButton>
                            </f:facet>
                            <h:panelGrid id="gpDetail" columns="1">
                                <h:panelGrid id="gpDetailText" columns="2">
                                    <h:outputText id="lblName" value="Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtName" value="#{investigationController.current.name}" required="true" ></h:inputText>
                                    <h:outputText id="lblAddress" value="Printing Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtAddress"  class="pdInputText" value="#{investigationController.current.printName}"  ></h:inputText>
                                    <h:outputText id="lblFullName" value="Full Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtFullName"  class="pdInputText" value="#{investigationController.current.fullName}"  ></h:inputText>

                                    <h:outputText value="Invesitgation Category" ></h:outputText>
                                    <h:selectOneListbox id="cmbCat"  size="1" value="#{investigationController.current.investigationCategory}" >
                                        <f:selectItem itemLabel="Please select a category"/>
                                        <f:selectItems value="#{investigationCategoryController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>
                                    <h:outputText value="Invesitgation Tube" ></h:outputText>
                                    <h:selectOneListbox id="cmbTube" size="1" value="#{investigationController.current.investigationTube }" >
                                        <f:selectItem itemLabel="Please select a Tube"/>
                                        <f:selectItems value="#{investigationTubeController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>

                                    <p:selectBooleanCheckbox   id="chkBilledAs" value="#{investigationController.billedAs}" itemLabel="Billed as a seperate investigation"  >
                                        <p:ajax event="change" process="@this" update="billedAsIx" />
                                    </p:selectBooleanCheckbox>
                                    <p:autoComplete converter="ixcon"  disabled="#{!investigationController.billedAs}" widgetVar="aIx1" id="billedAsIx" forceSelection="true" value="#{investigationController.current.billedAs}" completeMethod="#{investigationController.completeItem}" var="ix1" itemLabel="#{ix1.name}" itemValue="#{ix1}" size="30"  style="width: 400px;">
                                    </p:autoComplete>

                                    <p:selectBooleanCheckbox  id="chkReportedAs" value="#{investigationController.reportedAs}" itemLabel="Reported as a seperate investigation" >
                                        <p:ajax event="change" process="@this" update="reportedAsIx" />
                                    </p:selectBooleanCheckbox>
                                    <p:autoComplete converter="ixcon" disabled="#{!investigationController.reportedAs}" widgetVar="aIx2" id="reportedAsIx" forceSelection="true" value="#{investigationController.current.reportedAs}" completeMethod="#{investigationController.completeItem}" var="ix2" itemLabel="#{ix2.name}" itemValue="#{ix2}" size="30"  style="width: 400px;">
                                    </p:autoComplete>


                                    <h:outputText value="Sample" ></h:outputText>
                                    <h:selectOneListbox id="cmbSample" size="1" value="#{investigationController.current.sample}" >
                                        <f:selectItem itemLabel="Please select a sample"/>
                                        <f:selectItems value="#{sampleController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>
                                    <h:outputText value="Sample Volume" ></h:outputText>
                                    <h:inputText autocomplete="off"  class="pdInputText" value="#{investigationController.current.sampleVolume}"  ></h:inputText>
                                    <h:outputText value="Institution" ></h:outputText>
                                    <h:selectOneListbox id="cmbIns" size="1" value="#{investigationController.current.institution}" >
                                        <f:selectItem itemLabel="Please select a Institution"/>
                                        <f:selectItems value="#{institutionController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>
                                    <h:outputText value="Department" ></h:outputText>
                                    <h:selectOneListbox id="cmbDep" size="1" value="#{investigationController.current.department}" >
                                        <f:selectItem itemLabel="Please select a Department"/>
                                        <f:selectItems value="#{departmentController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>

                                    <h:outputText value="" ></h:outputText>
                                    <p:selectBooleanCheckbox value="#{investigationController.current.userChangable}" itemLabel="Can change Rate"/>

                                    <h:outputText value="" ></h:outputText>
                                    <p:selectBooleanCheckbox value="#{investigationController.current.discountAllowed}" itemLabel="Discount Allowed"/>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>

        <h:form>
            
            
            
            
        </h:form>
        
        
    </ui:define>

</ui:composition>
